<?php
class GoodsSellAction extends SzAbstractAction
{
    protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_STRING,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT
    );

    /**
     * 商品出售
     *
     * @param int $userId
     * @param string $gridId
     * @param int $girdLayer
     * @param int $reqTime
     * @return SzResponse
     */
    public function execute($userId, $gridId, $girdLayer, $reqTime)
    {
        if (!GameService::get()->verifySysUnlock($userId, GameConst::FUNC_FLOWER_SHOP_SELL)) {
            return $this->buildResponse(false);
        }

        GameService::get()->validateMultiRequestTimeDelta($userId, $reqTime);

        /**
         * @var GoodsVo $goods
         * @var ModuleProfileInfoVoList $profileInfoList
         */
        list($goods, $profileInfoList) = GoodsService::get()->sell($userId, $gridId, $girdLayer);
        return $this->buildResponse(array(
            'goods' => $goods->toArray(),
            'profileInfoList' => $profileInfoList->toArray()
        ));
    }
}